package com.hongkzh.www.look.media.view.adapter;

/**
 * Created by as on 2018/4/12.
 */

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import com.hongkzh.www.R;

import java.util.ArrayList;

/**
 * 三级目录的 地区 的数据适配器
 * @author Administrator
 *
 */
public class CityThirdAdapter extends BaseAdapter {

    private ArrayList<String> third_List;
    private Context context;
    private int root_position;
    private LayoutInflater inflater;

    public CityThirdAdapter(Context context, ArrayList<String> sub_items,
                            int position) {
        this.context = context;
        inflater = LayoutInflater.from(context);
        this.third_List = sub_items;
        this.root_position = position;
    }

    @Override
    public int getCount() {
        // TODO Auto-generated method stub
        return third_List.size();
    }

    @Override
    public String getItem(int position) {
        // TODO Auto-generated method stub
        return third_List.get(position);
    }

    @Override
    public long getItemId(int position) {
        // TODO Auto-generated method stub
        return position;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        // TODO Auto-generated method stub
        ViewHolder holder;
        if (convertView == null) {

            holder = new ViewHolder();
            convertView = (View) inflater.inflate(R.layout.item_trade_listview,
                    parent, false);
            holder.item_text = (TextView) convertView
                    .findViewById(R.id.item_name_text);
            convertView.setTag(holder);
        } else {
            holder = (ViewHolder) convertView.getTag();
        }
        holder.item_text.setText(third_List.get(position));
        return convertView;
    }
    class ViewHolder{
        TextView item_text;
    }

}
